import { Component, ViewChild, OnInit } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { NavbarService } from '../../component/navbar/navbar.service';
import { UserService } from '../../service/user.service';
import { User } from '../../domain/user';
import { PagerComponent } from '../../component/pager/pager.component';

@Component({
    templateUrl: 'app/page/user/userInfo.component.html',
    providers: [UserService],
})
export class UserInfoComponent implements OnInit {
    private title = "用户详情";
    private subTitle = "查看用户的详细信息";
    private user: User = new User();
    private fromDate: any = "2017-2-10";
    private toDate: any = "2017-2-11";

    @ViewChild(PagerComponent)
    private pager: PagerComponent;

    constructor(
        private route: ActivatedRoute,
        private userSvr: UserService
    ) { }

    async ngOnInit() {
        // (+) converts string 'id' to a number
        let id = +this.route.snapshot.params['id'];
        this.user = await this.userSvr.GetUserInfo(id);
        this.title = "用户【" + this.user.userNick + "】的详情";

        // this.pager.Load(100);
    }

    searchClick() {
        console.log(this.fromDate, this.toDate);
    }
}